package main

import (
    "facecat"
    "io/ioutil"
)

/*
*视图的鼠标按下方法
*view 视图
*mp 坐标
*buttons 按钮 0未按下 1左键 2右键
*clicks 点击次数
*delta 滚轮值
*/
func OnMouseDown(view *facecat.FCView, mp facecat.FCPoint, buttons int, clicks int, delta int){
	facecat.OnMouseDownDefault(view, mp, buttons, clicks, delta)
    if(buttons == 2){
        gMenu.Location = view.GetPaint().TouchDownPoint
        gMenu.Visible = true
        facecat.AdjustMenu(gMenu)
        facecat.Invalidate(gMenu.GetPaint())
    }
}

var gPaint = facecat.CreatePaint()
var gMenu = new(facecat.FCView)

func WndProc(hwnd facecat.HWND, msg uint32, wParam, lParam uintptr) (result uintptr) {
    return facecat.WndProcDefault(gPaint, hwnd, msg, wParam, lParam)
}

func main() {
    facecat.CreateMainWindow(gPaint, "FaceCat-Go", WndProc)
    xmlStr, _ := ioutil.ReadFile("xml//menuexample.xml")
    facecat.RenderFaceCat(gPaint, string(xmlStr))
    gMenu = facecat.CreateView("menu")
    gMenu.Size = facecat.CreateSize(100, 300)
    facecat.AddView(gMenu, gPaint)
    for i := 0; i < 10; i++{
        menuItem := facecat.CreateView("menuitem")
        menuItem.Text = "菜单项"
        facecat.AddMenuItem(menuItem, gMenu)
        for j := 0; j < 10; j++{
            subMenuItem := facecat.CreateView("menuitem")
            subMenuItem.Text = "子菜单项"
            facecat.AddMenuItemToParent(subMenuItem, menuItem)
            for z := 0; z < 10; z++{
                sunMenuItem :=  facecat.CreateView("menuitem")
                sunMenuItem.Text = "孙菜单项"
                facecat.AddMenuItemToParent(sunMenuItem, subMenuItem)   
            }
        }
    }
    facecat.ShowWindow(gPaint)
}